<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<pre>
    计算属性：基于它们的依赖进行缓存（只有在它们依赖的发生改变时才会重新计算）
    方法：只要发生重新渲染，方法总会执行该函数
</pre>
<div id="app">
   <p>firstName:{{firstName}}</p>
   <p>lastName:{{lastName}}</p>
   <p>fullName:{{fullName}}</p>
   <p>fullName2:{{fullName2}}</p>
</div>
</body>
<script src="../../vender/vue@2.4.2.js"></script>
<script>

    var vm=new Vue({
        el:'#app',
        data:{
            firstName:'Foo',
            lastName:'Bar',
            fullName:'Foo Bar'
        },
        watch:{
            firstName: function (val) {
                this.fullName=val+' '+this.lastName;
            },
            lastName: function (val) {
                this.fullName=this.firstName+' '+val;
            }
        },
        computed:{
            fullName2: function () {
                console.log('fullName2:',this.firstName+' '+this.lastName);
                return this.firstName+' '+this.lastName;
            }
        }
    });

</script>
</html>